-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: Testing for mixed int/str Index #61349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…t_values_invalid_na_position
…t_values_with_missing
…xes\multi\test_setops.py
@xaris96 Can you fix the broken tests and remove all your debug files from this PR please? |
scripts/cibw_before_test_windows.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should have not been changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should have not been changed
pandas/tests/window/test_rolling.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not have changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I’m aware — as I mentioned earlier, I ran into an unexpected issue with the test_rolling.py file. It had been working fine before and I hadn’t modified it, so I’m not sure why it started failing. Please let me know if it is a common failure or if there is any other solution for this.
…before_test_windows.sh, undo the test_rolling.py changes
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
mark = pytest.mark.xfail(reason="complex objects are not comparable") | ||
request.applymarker(mark) | ||
request.applymarker(pytest.mark.xfail(reason="GH 14833", strict=False)) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove all these return
s? We want to apply the mark
and then let the test run as normal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review the diff and consistently use these following conventions
- Use
inferred_type
to check for the newmixed-int-string
case you added - If a test fails, do not
astype
orpytest.skip
. Add anpytest.mark.xfail
to the test instead
# special case for mixed types | ||
if index.inferred_type == "mixed": | ||
index = index.map(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an xfail
marker here instead?
if len({type(x) for x in index_with_missing if pd.notna(x)}) > 1: | ||
index_with_missing = index_with_missing.map(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check .inferred_type
and xfail
if needed.
non_na_values = [x for x in index_with_missing if pd.notna(x)] | ||
if len({type(x) for x in non_na_values}) > 1: | ||
index_with_missing = index_with_missing.map(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check .inferred_type
and xfail
if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this file? These tests are exercised across the test suite
has_str = any(isinstance(x, str) for x in index) | ||
has_int = any(isinstance(x, int) for x in index) | ||
if has_str and has_int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check .inferred_type
.
@pytest.mark.parametrize( | ||
"index_or_series_obj", [[1, 2, 3], ["a", "b", "c"], [0, "a", 1, "b", 2, "c"]] | ||
) | ||
@pytest.mark.parametrize("sort", [True, False]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pytest.mark.parametrize( | |
"index_or_series_obj", [[1, 2, 3], ["a", "b", "c"], [0, "a", 1, "b", 2, "c"]] | |
) | |
@pytest.mark.parametrize("sort", [True, False]) |
This overrides the original fixtures being used here
|
||
for idx in [index1, index2]: | ||
for lvl in range(idx.nlevels): | ||
if has_mixed_types(idx.get_level_values(lvl)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check inferred_type
pytest.skip( | ||
f"Mixed types in MultiIndex level {lvl} are not orderable" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an xfail
marker instead
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.